﻿using System;
using WindowsLive.Writer.Api;

namespace WordpressCodePlugin
{
    public class PluginSettings
    {
        private const string LANGUAGE = "LANGUAGE";
        private const string AUTOLINKS = "AUTOLINKS";
        private const string COLLAPSE = "COLLAPSE";
        private const string FIRSTLINE = "FIRSTLINE";
        private const string GUTTER = "GUTTER";
        private const string HIGHLIGHT = "HIGHLIGHT";
        private const string HTMLSCRIPT = "HTMLSCRIPT";
        private const string LIGHT = "LIGHT";
        private const string PADLINENUMBERS = "PADLINENUMBERS";
        private const string TOOLBAR = "TOOLBAR";
        private const string WRAPLINES = "WRAPLINES";
        private const string PREVIEWTEXT = "PREVIEWTEXT";
        private const string CODE = "CODE";

        private IProperties m_properties;

        public PluginSettings(IProperties properties)
        {
            m_properties = properties;
        }

        public string Language
        {
            get { return m_properties.GetString(LANGUAGE, "csharp"); }
            set { m_properties.SetString(LANGUAGE, value); }
        }

        public bool AutoLinks
        {
            get { return m_properties.GetBoolean(AUTOLINKS, true); }
            set { m_properties.SetBoolean(AUTOLINKS, value); }
        }

        public bool Collapse
        {
            get { return m_properties.GetBoolean(COLLAPSE, false); }
            set { m_properties.SetBoolean(COLLAPSE, value); }
        }

        public string FirstLine
        {
            get { return m_properties.GetString(FIRSTLINE, ""); }
            set { m_properties.SetString(FIRSTLINE, value); }
        }

        public bool Gutter
        {
            get { return m_properties.GetBoolean(GUTTER, true); }
            set { m_properties.SetBoolean(GUTTER, value); }
        }

        public string Highlight
        {
            get { return m_properties.GetString(HIGHLIGHT, ""); }
            set { m_properties.SetString(HIGHLIGHT, value); }
        }

        public bool HTMLScript
        {
            get { return m_properties.GetBoolean(HTMLSCRIPT, false); }
            set { m_properties.SetBoolean(HTMLSCRIPT, value); }
        }

        public bool Light
        {
            get { return m_properties.GetBoolean(LIGHT, false); }
            set { m_properties.SetBoolean(LIGHT, value); }
        }

        public bool PadLineNumbers
        {
            get { return m_properties.GetBoolean(PADLINENUMBERS, true); }
            set { m_properties.SetBoolean(PADLINENUMBERS, value); }
        }

        public bool Toolbars
        {
            get { return m_properties.GetBoolean(TOOLBAR, true); }
            set { m_properties.SetBoolean(TOOLBAR, value); }
        }

        public bool WrapLines
        {
            get { return m_properties.GetBoolean(WRAPLINES, false); }
            set { m_properties.SetBoolean(WRAPLINES, value); }
        }

        public string PreviewText
        {
            get { return m_properties.GetString(PREVIEWTEXT, "Inserted code"); }
            set { m_properties.SetString(PREVIEWTEXT, value); }
        }

        public string Code
        {
            get { return m_properties.GetString(CODE, ""); }
            set { m_properties.SetString(CODE, value); }
        }

        public void Reset()
        {
            m_properties.RemoveAll();
        }

    }
}
